package com.isoft.hospital.service.Impl;

import com.isoft.hospital.common.ResponseData;
import com.isoft.hospital.dao.WorkDao;
import com.isoft.hospital.entity.Department;
import com.isoft.hospital.entity.Work;
import com.isoft.hospital.service.WorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WorkServiceImpl  implements WorkService {
    @Autowired
    private WorkDao dao;
    @Override
    public ResponseData update(Work work) {
        int temp = dao.update(work);
        ResponseData responseData = new ResponseData();
        if (temp > 0) {
            responseData.setCode(0);
            responseData.setMsg("ok");
        } else {
            responseData.setCode(1);
            responseData.setMsg("no");
        }
        return responseData;
    }

    @Override
    public ResponseData selectAll() {
        List<Work> list = dao.selectAll();
        ResponseData responseData = new ResponseData();
        if (list != null) {
            responseData.setCode(0);
            responseData.setMsg("ok");
            responseData.setData(list);
        } else {
            responseData.setCode(1);
            responseData.setMsg("no");
        }
        return responseData;
    }
}
